<!--
 * @Descripttion: 
 * @version: 
 * @Author: yuanliutech
 * @Date: 2024-07-19 10:07:16
 * @LastEditors: yuanliutech@lwj
 * @LastEditTime: 2024-09-14 15:20:11
-->
<template>
  <div>
    <el-dialog
      :title="'批量设置安装备注'"
      :visible.sync="dialogVisible"
      width="450px"
      :before-close="closeDialog"
      :close-on-click-modal="false"
    >
      <el-form :model="addForm" :rules="rules" ref="refForm" label-width="90px">
        <el-form-item size="small" label="安装备注" prop="remark">
          <el-input
            v-model="addForm.remark"
            placeholder="请输入安装备注"
            maxlength="10"
            clearable
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="closeDialog" class="cancel-button">取 消</el-button>
        <el-button
          size="small"
          @click="submit"
          v-preventReClick="1000" class="confirm-button"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
  
  <script>
import { reqBatchUpRemark } from "@api/api.js";

export default {
  props: ["idList"],
  data() {
    return {
      dialogVisible: false,
      addForm: {
        remark: "",
      },
      rules: {
        remark: [
          {
            required: true,
            message: "请输入安装备注",
            trigger: ["blur", "change"],
          },
        ],
      },
    };
  },
  computed: {},
  watch: {},
  mounted() {},
  methods: {
    // 点击绑定
    submit() {
      this.$refs.refForm.validate(async (valid) => {
        if (!valid) return;
        let { remark } = this.addForm;
        // 批量下发
        const res = await reqBatchUpRemark({
          remark,
          idList: this.idList,
        });
        if (res.code !== 20000) return this.$modal.notifyWarning(res.message);
        this.$modal.notifySuccess("批量修改安装备注成功！");
        this.$parent.clearSelections(); //清空复选框
        this.$parent.getDataList();
        this.closeDialog();
      });
    },
    // 点击关闭弹框
    closeDialog() {
      this.$refs.refForm.resetFields();
      this.dialogVisible = false;
      this.addForm = {
        remark: "",
      };
    },
  },
  deactivated() {
    if(this.$refs.refForm!=null){
      this.closeDialog();
    }
  },
};
</script>
  
  <style lang="less" scoped>
</style>
  